package com.jsonal.controller;

import com.jsonal.entity.SysFileDtBean;
import com.jsonal.service.SystemService;
import com.jsonal.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: jsonal
 * @Description:
 * @Date: 2020/11/19 17:02
 * @Version: 1.0
 */
@Controller
public class SystemController extends BaseController {

    @Autowired
    private SystemService systemService;

    @RequestMapping(value = "/managers/getCarouselList", method = RequestMethod.GET)
    @ResponseBody
    public Result getCarouselList(SysFileDtBean sysFileDtBean) {
        return systemService.getCarouselList(sysFileDtBean);
    }

    @RequestMapping(value = "/managers/changeCarouselState/{fileDtId}")
    @ResponseBody
    public Result changeCarouselState(@PathVariable String fileDtId) {
        if ("".equals(fileDtId)) {
            return new Result(false, "id 不能为空!");
        }
        return systemService.changeCarouselState(fileDtId);
    }

    @RequestMapping(value = "/api/getCarousel", method = RequestMethod.GET)
    @ResponseBody
    public Result getCarousel(SysFileDtBean sysFileDtBean) {
        return systemService.getCarousel(sysFileDtBean);
    }

    /**
     * 模糊查询接口
     */
    @RequestMapping(value = "/api/search", method = RequestMethod.GET)
    @ResponseBody
    public Result search(@RequestParam String keyword) {
        return systemService.search(keyword);
    }
}
